<?php
use yii\helpers\Html;
use yii\widgets\ActiveForm;
use yii\helpers\ArrayHelper;
use yii\helpers\Url;
use yii\captcha\Captcha;

$this->title = '个人基本信息';
?>
<?php echo $this->render('_centerHeader') ?>
<link rel="stylesheet" type="text/css" href="/assets/style/public.css">
<!--主体开始-->
<style type="text/css">
.help-block{
    padding-left: 95px;
}
</style>
<div class="main-area" style=" background: #f5f5f5;">
    <div class="container">
        <div class="column-layout">
            <!-- main-area-left start  -->
<div class="column-col column-full main-area-left">
<div class="main-area-leftin tab-box">
<div class="ibox">
    <div class="ibox-in">
        <div class="ibox-head">
            <ul class="tab-list" role="tablist">
                <li role="presentation" class="active">
                    <a href="#BASIC_DOC" aria-controls="BASIC_DOC" role="tab" data-toggle="tab">基本信息</a>
                </li>
            </ul>
        </div>
        <div class="ibox-body tab-pane-list set-form-box">
            <!-- 基本资料  -->
            <div role="tabpanel" class="tab-pane active" id="BASIC_DOC">

            <?php $form = ActiveForm::begin([
            'action' => ['center/savecenter'],
            'method'=> 'post',
            'class' => 'form-horizontal uc-form',
            'id'=> 'user-form',
            
            ]); ?>	

            <!--隐藏域-->
            <?= $form->field($model, 'user_id')->hiddenInput(['value'=>$model->user_id]) ?>

                <!--昵称-->
                <?= $form->field($model, 'user_name', 
                [
                    'inputOptions' => ['maxlength' => 20,'class'=>'form-control'],
                    'enableAjaxValidation'=>true,
                    'enableClientValidation' => true,
                    'template' => '<div class="form-group">{label}{input}</div>{error}',
                ])->textInput() 
                ?>

                <!--手机-->
                <?= $form->field($model, 'user_phone', 
                [
                    'inputOptions' => ['maxlength' => 20,'class'=>'form-control','disabled' => true],
                    'template' => '<div class="form-group">{label}{input}&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="updMobile()">修改手机号<a></div>{error}',
                ])->textInput() 
                ?>

                <!--邮箱-->
                <?= $form->field($model, 'user_email', 
                [
                    'inputOptions' => ['maxlength' => 20,'class'=>'form-control','disabled' => true],
                    'template' => '<div class="form-group">{label}{input}&nbsp;&nbsp;&nbsp;<a href="javascript:void(0);" onclick="updEmail()">修改邮箱<a></div>{error}',
                ])->textInput() 
                ?>
                <style type="text/css">
                    .city{
                        width: 150px;
                    }
                </style>
                <!--城市-->
                <div class="form-group">
                    <label class="control-label">城市:</label>
                    <?= Html::dropDownList('province_id', $model->province_id, ArrayHelper::map($provinces,'id', 'province_id'), ['class' => 'province_id form-control','style'=>'width: 150px;']);?>
                    <?= Html::dropDownList('city_id', $model->city_id, ArrayHelper::map($city,'id', 'city_id'), ['class' => 'city_id form-control','id'=>'city_id','style'=>'width: 150px;']);?>
                    <?= Html::dropDownList('area_id', $model->area_id, ArrayHelper::map($area,'id', 'area_id'), ['class' => 'area_id form-control','id'=>'area_id','style'=>'width: 150px;']);?>
			    </div>
                

                <!--性别-->
                <?= $form->field($model, 'user_sex')->radioList(['0'=>'保密','1'=>'男','2'=>'女'],['separator'=>"&nbsp;&nbsp;&nbsp;", 'style' => 'display: inline-block; line-height: 21px;']); ?> 


                <!--标签-->
                <style type="text/css">
                    .add_biaoqian_r{
                        margin:5px 0px 0px 100px;
                        font-size: 14px;
                    }
                    .add_biaoqian_r li{
                        margin-right: 5px;
                    }
                    .add_biaoqian_r li i{
                        cursor: pointer;
                    }
                    .edit_biaoqian_k i{
                        cursor: pointer;
                    }
                </style>
                <div class='form-group' style="position: relative;">
				<span class="control-label" style='position: absolute;top: 0px;'>标签:</span>
                <div style="clear:both"></div>
                <div class='form-control' style='width:455px;height:100px;margin-left:100px;'>
                    <div class="biaoqian_k edit_biaoqian_k">
                        <ul>
                           <?php if(!empty($hobbyrole)){?>
							  <?php foreach($hobbyrole as $k=>$vo){?>
								<li style='float:left'><p><b style='color:#000'><?php echo $vo['hobby_name'];?></b><i>×</i></p><input type='hidden' name='User[hobby_id][]' value='<?php echo $vo['hobby_id']?>'/></li>
							  <?php }?>
							<?php }else{}?>
                        </ul>
                    </div>
                </div>
                <div class="add_biaoqian_r">
                    <ol>
					<?php if(!empty($db)){?>
                      <?php foreach($db as $k=>$vo){?>
                        <li style="float:left"><p><i name="<?php echo $vo['hobby_id']?>">+</i><b><?php echo $vo['hobby_name'];?></b></p></li>
                      <?php }?>
                    <?php }else{}?>
                    </ol>
                  
                </div>
				</div>
                <div style="clear: both;height:20px;"></div>

                <!--个人签名-->
                <?= $form->field($model, 'user_sign', 
                [
                    'inputOptions' => ['class'=>'form-control',
                    'placeholder'=>'这位同学很懒，什么也没留下', 'style' => 'width: 460px;margin-left: 100px;'],
                    'labelOptions' => [
                        'style' => 'position: absolute; top: 0px; left: 25px;',
                    ],
                    'template' => '<div class="form-group">{label}{input}</div>{error}',
                ])->textarea(['rows'=>4,'cols'=>20])
                ?>
                
                <!--提交按钮-->
                <div class="form-group">
                <?= Html::submitButton('保存', ['class' => 'btn btn-micv5 btn-block','id'=>'user_save','style'=>'margin:0px auto;']) ?>
                </div>

                
                  
                <?php ActiveForm::end(); ?>

                
            </div>
        </div>
    </div>
</div>
</div>
</div>
            <!-- main-area-left end  -->
            <!-- main-area-right start  -->
            <div dy-v="00-00-11-11" class="column-col main-area-right">
                
                <!-- 课程推荐 -->
                <?php echo $this->render('../common/_courseRecommend') ?>
 
                <!-- 名师推荐 -->
                <?php echo $this->render('../common/_teacherRecommend') ?>

                <!-- 图片广告 -->
                <?php echo  $this->render('../common/_adRecommend') ?>
            </div>
            <!-- main-area-right end  -->
        </div>
    </div>
</div>


<!--绑定手机验证码-->
<div class="modal fade" id="newMobile" style="top: 100px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div style="margin: 0px auto;" class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="newMobilnumberNextModalLabel">手机验证</h4>
            </div>
            <div class="modal-body">
                <section class="box-forgetpsw v5-input-txt" id="box-forgetpsw-mobile-code">
                    <form id="mobile_code_update_mobile_form" action="/user/mobile/update/" method="post" onsubmit="mobile_code_update_mobile_form_submit();return false;" autocomplete="off">
                        <input name="csrfmiddlewaretoken" value="rtYLuLYwcZh4SiYSIXlrcgGqfuYmL3r4" type="hidden">
                        <ul>
                            <li class="form-group" id="mobile_code_password_form_message">手机短信验证码已发送，请查收！</li>
                            <li class="form-group"><input value="13782519376" id="id_mobile_f" name="mobile_f" type="hidden"></li>
                            <li class="form-group"><input class="form-control" id="id_mobile_code_f" name="mobile_code_f" placeholder="请输入短信验证码" type="text"></li>
                        </ul>
                        <div>
                            <button type="button" class="btn btn-micv5 btn-block" onclick="mobile_code_update_mobile_form_submit()">确定</button>
                        </div>
                        <div id="update_mobile_tips" class="tips-error bg-danger">错误提示</div>
                    </form>
                </section>
            </div>
        </div>
    </div>
</div>

<!--新手机弹窗-->
<div class="modal fade" id="updMobile" style="top: 100px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div style="margin: 0px auto;" class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="newMobilnumberModalLabel">新手机号</h4>
            </div>
            <div class="modal-body">
                <section class="box-newMobilnumber" id="box-newMobilnumber">
					<?php $form = ActiveForm::begin([
						'action' => ['center/newphone'],
						'enableAjaxValidation'=>true,
                        'enableClientValidation'=>true,
						'method'=>'post',
						'id'=>'codes-form',
					])?>
                    <!-- <form id="new_mobile_form" action="/user/mobile/update/sendsms/" method="post" onsubmit="new_mobile_form_submit();return false;" autocomplete="off"> -->
                        <input name="csrfmiddlewaretoken" value="rtYLuLYwcZh4SiYSIXlrcgGqfuYmL3r4" type="hidden">
                    <ul class="form-horizontal v5-form-horizontal">
                        <li class="row form-group">
                            <div class="form-group cf">
								<?= $form->field($code,'user_phone',
                            [
                                'inputOptions' => ['placeholder'=>'请输入手机号', 'class' => 'form-control'],
                                'enableAjaxValidation'=>true,
                                'enableClientValidation' => true,
                                'template' => '<div class="form-group">{input}</div>{error}',
                            ])->textInput()
                            ?>
							</div>
                        </li>
                        <li class="row form-group">
                            <div class="form-group cf">
							<?= $form->field($code, 'verifyCode')->widget(Captcha::className(),[
							   'template' => '{input}{image}',
							   'imageOptions' => ['alt' => '验证码'],
							   'captchaAction' => 'center/captcha',
							   'options' =>['placeholder' => '请输入验证码', 'class' => 'form-control form-control-captcha fl'],
							]);?>
							</div>
                        </li>
                        <li class="row form-group v5-pdt">
                            <div class="col-sm-2"></div>
                            <div class="col-sm-8">
                               <!-- <button type="button" class="btn btn-micv5 btn-md btn-block" onclick="new_mobile_submit()">下一步</button> -->
							   <?= Html::Button('下一步', ['class' => 'btn btn-micv5 btn-md btn-block','id'=>'user_phone']) ?>
							
                                <input id="id_uid_um" name="uid_um" value="73826" type="hidden">
                            </div>
                            <div class="col-sm-2"></div>
                        </li>
                    </ul>
                   <?php $form = ActiveForm::end()?>
                    <div style="display: none;" id="new_mobile_tips" class="tips-error bg-danger">错误提示</div>
                </section>
            </div>
        </div>
    </div>
</div>


<!--修改邮箱-->
<div class="modal fade" id="updEmail" style="top: 100px;" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div style="margin: 0px auto;" class="modal-dialog modal-sm">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button>
                <h4 class="modal-title" id="addemailModalLabel">新邮箱</h4>
            </div>
            <div class="modal-body">
                <section class="box-addemail" id="box-addemail">
                    <!-- <form id="new_email_form" action="/user/email/update/" method="post" onsubmit="new_email_form_submit();return false;" autocomplete="off"> -->
					<?php $form = ActiveForm::begin([
						'action' => ['center/newemail'],
						'enableAjaxValidation'=>true,
                        'enableClientValidation'=>true,
						'method'=>'post',
						'id'=>'codee-form',
					])?>
                        <input name="csrfmiddlewaretoken" value="rtYLuLYwcZh4SiYSIXlrcgGqfuYmL3r4" type="hidden">
                    <ul class="form-horizontal v5-form-horizontal">
                        <li class="row form-group">
                            <div class="form-group cf"><?= $form->field($codee,'user_email',
                            [
                                'inputOptions' => ['placeholder'=>'请输入邮箱', 'class' => 'form-control'],
                                'enableAjaxValidation'=>true,
                                'enableClientValidation' => true,
                                'template' => '<div class="form-group">{input}</div>{error}',
                            ])->textInput()
                            ?></div>
                        </li>
                        <li class="row form-group">
						
                            <div class="form-group cf"><?= $form->field($codee, 'verify')->widget(Captcha::className(),[
							   'template' => '{input}{image}',
							   'imageOptions' => ['alt' => '验证码'],
							   'captchaAction' => 'center/captcha',
							   'options' =>['placeholder' => '请输入验证码', 'class' => 'form-control form-control-captcha fl'],
							]);?></div>
                        </li>
                        <li class="row form-group v5-pdt">
                            <div class="col-sm-2"></div>
                            <div class="col-sm-8">
                                <!-- <button type="button" class="btn btn-micv5 btn-md btn-block" onclick="new_email_form_submit()">确定</button> -->
								<?= Html::Button('下一步', ['class' => 'btn btn-micv5 btn-md btn-block','id'=>'user_email']) ?>
                                <input id="id_uid_ue" name="uid_ue" value="73826" type="hidden">
                            </div>
                            <div class="col-sm-2"></div>
                        </li>
                    </ul>
                    <div style="display: none;" id="new_email_tips" class="tips-error bg-danger">错误提示</div>
                    <?php $form = ActiveForm::end()?>
                </section>
            </div>
        </div>
    </div>
</div>



<script>
/*标签添加*/
$(".edit_biaoqian_k ul").on("click","li p i",function(){
  var oneBq=$(this).parents("li")
  $(this).parents("p").next('input').remove();
  oneBq.hide();
  var addText=$(this).siblings("b").text();
  $(".add_biaoqian_r ol").append("<li style='float:left'><p><i>+</i><b>"+addText+"</b></p></li>")
})
$(".add_biaoqian_r ol").on("click","li p i",function(){
  var oneBq=$(this).parents("li")
  oneBq.hide();
  var addText=$(this).siblings("b").text();
  var hobby_id = $(this).attr('name');
  $(".edit_biaoqian_k ul").append("<li style='float:left'><p><b style='color:#000'>"+addText+"</b><i>×</i></p><input type='hidden' name='User[hobby_id][]' value='"+hobby_id+"'/></li>")
})

// -----------------------------------弹窗---------------------------------------------\\
$("#user_phone").click(function(){
	var user_email_phone = $("#codes-user_phone").val();
	var verifycode = $("#codes-verifycode").val();
	$.ajax({
		   type: "POST",
		   url: "<?= Url::to(['center/newphone'])?>",
		   data: "user_phone="+user_email_phone+"&verifycode="+verifycode,
		   success: function(msg){
			 if(msg == 1){
				jq('#updMobile').modal('hide');
				jq('#newMobile').modal('show');
			 }else if(msg == 2){
				alert('发送失败,请从新请求')
			 }else if(msg == 3){
				alert('请填写正确的手机')
			 }else{
				alert(msg)
			 }
		   }
		});
})

$("#user_email").click(function(){
	var user_email_phone = $("#codes-user_email").val();
	var verifycode = $("#codes-verify").val();
	$.ajax({
		   type: "POST",
		   url: "<?= Url::to(['center/newemail'])?>",
		   data: "user_email_phone="+user_email_phone+"&verifycode="+verifycode,
		   success: function(msg){
			 if(msg == 1){
				jq('#updMobile').modal('hide');
				jq('#newMobile').modal('show');
			 }else if(msg == 2){
				alert('发送失败,请从新请求')
			 }else if(msg == 3){
				alert('请填写正确的手机')
			 }else{
				alert(msg)
			 }
		   }
		});
})

//城市
$(document).on('change', '.province_id', function(){
        var id=$(this).val();
		var objs = $(this);
		
        //var next=$(this).parent().next();
        //var nexttwo=next.next();
        //alert(next);
        $.ajax({
            type: "POST",
            url:"<?= Url::to(['center/sel'])?>",
            data: "id="+id,
            dataType:"json",
            success: function(obj){
                var str="";
                var i=0;
                for(i;i<obj.length;i++){
                    str+="<option value="+obj[i]['region_id']+">"+obj[i]['region_name'];
                }
                objs.next().html(str);
				objs.next().next().html("<option value=''>请选择...");
            }
        });
    })
//城市
$(document).on('click', '.city_id', function(){
        var id=$(this).val();		
        var next=$(this).next();
        //var nexttwo=next.next();
        //alert(next);
        $.ajax({
            type: "POST",
            url:"<?= Url::to(['center/sel'])?>",
            data: "id="+id,
            dataType:"json",
            success: function(obj){
                var str="";
                var i=0;
                for(i;i<obj.length;i++){
                    str+="<option value="+obj[i]['region_id']+" class='city_id'>"+obj[i]['region_name'];
                }
                next.html(str);
                //obj.next().nextAll().html("<option>哈哈哈哈</option>");
                //nexttwo.html("<option value=0>请选择...");
            }
        });
    })
</script>
